import request from '@/utils/request'
import type { GetCourseContentResponse, GetTipContentResponse, UpdateTipContent,UpdateCourseContent } from '@/api/course/type.d.ts'

enum API {
  KNOWLEDGE_GET_URL = '/courseware/knowledge/get',
  TIP_GET_URL = '/courseware/knowledge/get/point',
  TIP_UPDATE_POST_URL = '/courseware/knowledge/update/point',
  CONTENT_UPDATE_POST_URL = '/courseware/knowledge/update'
}

export const getCourseContents = (id: number) =>
  request.get<number, GetCourseContentResponse>(`${API.KNOWLEDGE_GET_URL}?id=${id}`)

export const getTipContents = (id: number) =>
  request.get<number, GetTipContentResponse>(`${API.TIP_GET_URL}?id=${id}`)

export const updateTipContents = (data: UpdateTipContent) =>
  request.post<UpdateTipContent, any>(API.TIP_UPDATE_POST_URL, data)

export const updateCourseContents = (data: UpdateCourseContent) =>
  request.post<UpdateCourseContent, any>(API.CONTENT_UPDATE_POST_URL, data)